﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Management/MedicalDirector/MasterDirect.master" AutoEventWireup="true" CodeFile="Quanlythuoc.aspx.cs" Inherits="Management_MedicalDirector_Quanlythuoc" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register Src="../Danhsachnhanvien.ascx" TagName="danhsachnhanvien" TagPrefix="uc2" %>
<%@ Register Src="../DanhSachThuoc.ascx" TagName="danhsachthuoc" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table style="width: 100%;">
        <tr>
            <td style="text-align: center; height: 24px;">
                <asp:Label ID="Label1" runat="server" Text="QUẢN LÝ THUỐC" Font-Size="X-Large" ForeColor="BlueViolet"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <table style="width: 100%;">
                    <tr>
                        <td style="width: 327px; text-align: center">
                            <asp:Label ID="Label2" runat="server" Text="Danh sách thuốc+ Vật tư tổng" Font-Size="Large" ForeColor="Red"></asp:Label>
                        </td>
                        <td style="text-align: center">
                            <asp:Label ID="Label3" runat="server" Text="Danh sách thuốc+Vật tư" Font-Size="Large" ForeColor="Red"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 327px">
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="IDDrug" DataSourceID="dsTong" AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" Width="300px" AllowSorting="True" BorderWidth="1px" BorderColor="Black">
                                <AlternatingRowStyle BackColor="White" />
                                <Columns>
                                    <asp:TemplateField HeaderText="Mã Thuốc" SortExpression="IDDrug">
                                        <EditItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("IDDrug") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("IDDrug") %>'></asp:Label>
                                        </ItemTemplate>
                                        <HeaderStyle Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                        <ItemStyle Height="15px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Tên Thuốc" SortExpression="Name">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>' Width="70px"></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                        </ItemTemplate>
                                        <HeaderStyle Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                        <ItemStyle Height="15px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Số lượng" SortExpression="Quantity">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Quantity") %>' Width="70px"></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Quantity") %>'></asp:Label>
                                        </ItemTemplate>
                                        <HeaderStyle Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                        <ItemStyle Height="15px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    </asp:TemplateField>
                                    <asp:TemplateField ShowHeader="False">
                                        <EditItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="cập nhật"></asp:LinkButton>
                                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="hủy"></asp:LinkButton>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="sửa"></asp:LinkButton>
                                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="xóa"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <EditRowStyle BackColor="#2461BF" />
                                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#EFF3FB" />
                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                <SortedDescendingHeaderStyle BackColor="#4870BE" />
                            </asp:GridView>
                            <asp:SqlDataSource ID="dsTong" runat="server" ConnectionString="<%$ ConnectionStrings:HOSPITALMANAGEMENTConnectionString %>" DeleteCommand="DELETE FROM [tbTotalDrug] WHERE [IDDrug] = @IDDrug" InsertCommand="INSERT INTO [tbTotalDrug] ([IDDrug], [Quantity]) VALUES (@IDDrug, @Quantity)" SelectCommand="SELECT [tbTotalDrug].[IDDrug],[tbDrug].[Name],[tbTotalDrug].[Quantity] FROM [tbTotalDrug],[tbDrug] where [tbDrug].[ID]=[tbTotalDrug].[IDDrug]" UpdateCommand="UPDATE [tbTotalDrug] SET [Quantity] = @Quantity WHERE [IDDrug] = @IDDrug">
                                <DeleteParameters>
                                    <asp:Parameter Name="IDDrug" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="IDDrug" Type="Int32" />
                                    <asp:Parameter Name="Quantity" Type="Int32" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="Quantity" Type="Int32" />
                                    <asp:Parameter Name="IDDrug" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                            <table style="width: 100%;">
                                <tr>
                                    <td style="width: 118px">
                                        <asp:DropDownList ID="dlQLthuoc" runat="server" DataSourceID="dropdown" DataTextField="Name" DataValueField="ID">
                                        </asp:DropDownList>
                                        <asp:SqlDataSource ID="dropdown" runat="server" ConnectionString="<%$ ConnectionStrings:HOSPITALMANAGEMENTConnectionString %>" SelectCommand="SELECT [ID], [Name] FROM [tbDrug]"></asp:SqlDataSource>
                                    </td>
                                    <td style="width: 54px">
                                        <asp:TextBox ID="cbNumber" runat="server" Width="41px"></asp:TextBox>
                                    </td>
                                    <td style="width: 94px">
                                        <asp:Button ID="btThem" runat="server" Text="Thêm" OnClick="btThem_Click" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td style="vertical-align: top;">
                            <asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
                                <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" DataSourceID="dsThuoc" ForeColor="#333333" GridLines="None" Height="163px" Width="600px" BorderWidth="1px" BorderColor="Black" HorizontalAlign="Center">
                                    <AlternatingRowStyle BackColor="White" />
                                    <Columns>
                                        <asp:TemplateField HeaderText="Mã" InsertVisible="False" SortExpression="ID">
                                            <EditItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                                            </ItemTemplate>
                                            <HeaderStyle Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                            <ItemStyle Height="15px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Loại" SortExpression="Type">
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="dlType" runat="server" Width="70px" SelectedIndex='<%# Bind("Type") %>'>
                                                    <asp:ListItem Value="0" Text="Thuốc"></asp:ListItem>
                                                    <asp:ListItem Value="1" Text="Vật tư"></asp:ListItem>
                                                </asp:DropDownList>                                                
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label2" runat="server" Text='<%# (int)Eval("Type")==0? "Thuốc": "Vật tư" %>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Tên" SortExpression="Name">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Name") %>' Width="70px"></asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Mô tả" SortExpression="Desc">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Desc") %>' Width="70px"></asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("Desc") %>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Đơn vị" SortExpression="UnitType">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("UnitType") %>' Width="70px"></asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label5" runat="server" Text='<%# Bind("UnitType") %>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Sử dụng" SortExpression="UseMethod">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("UseMethod") %>' Width="70px"></asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label6" runat="server" Text='<%# Bind("UseMethod") %>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Giá tiền" SortExpression="CostPerUnit">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CostPerUnit") %>' Width="70px"></asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label7" runat="server" Text='<%# Bind("CostPerUnit") %>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:CommandField CancelText="hủy" DeleteText="xóa" EditText="sửa" InsertText="thêm" ShowDeleteButton="True" ShowEditButton="True" UpdateText="cập nhật">
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:CommandField>
                                    </Columns>
                                    <EditRowStyle BackColor="#2461BF" />
                                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                    <RowStyle BackColor="#EFF3FB" />
                                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                                </asp:GridView>
                                <asp:SqlDataSource ID="dsThuoc" runat="server" ConnectionString="<%$ ConnectionStrings:HOSPITALMANAGEMENTConnectionString %>" DeleteCommand="DELETE FROM [tbDrug] WHERE [ID] = @ID" InsertCommand="INSERT INTO [tbDrug] ([Type], [Name], [Desc], [UnitType], [UseMethod], [CostPerUnit]) VALUES (@Type, @Name, @Desc, @UnitType, @UseMethod, @CostPerUnit)" SelectCommand="SELECT * FROM [tbDrug]" UpdateCommand="UPDATE [tbDrug] SET [Type] = @Type, [Name] = @Name, [Desc] = @Desc, [UnitType] = @UnitType, [UseMethod] = @UseMethod, [CostPerUnit] = @CostPerUnit WHERE [ID] = @ID">
                                    <DeleteParameters>
                                        <asp:Parameter Name="ID" Type="Int32" />
                                    </DeleteParameters>
                                    <InsertParameters>
                                        <asp:Parameter Name="Type" Type="Int32" />
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Desc" Type="String" />
                                        <asp:Parameter Name="UnitType" Type="String" />
                                        <asp:Parameter Name="UseMethod" Type="String" />
                                        <asp:Parameter Name="CostPerUnit" Type="Double" />
                                    </InsertParameters>
                                    <UpdateParameters>
                                        <asp:Parameter Name="Type" Type="Int32" />
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Desc" Type="String" />
                                        <asp:Parameter Name="UnitType" Type="String" />
                                        <asp:Parameter Name="UseMethod" Type="String" />
                                        <asp:Parameter Name="CostPerUnit" Type="Double" />
                                        <asp:Parameter Name="ID" Type="Int32" />
                                    </UpdateParameters>
                                </asp:SqlDataSource>
                                <br />
                                <table style="width: 100%;" border="1px">
                                    <tr>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label8" runat="server" Text="Mã"></asp:Label>
                                        </td>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label9" runat="server" Text="Loại"></asp:Label>
                                        </td>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label10" runat="server" Text="Tên"></asp:Label>
                                        </td>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label11" runat="server" Text="Mô tả"></asp:Label>
                                        </td>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label12" runat="server" Text="Đơn  vị"></asp:Label>
                                        </td>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label13" runat="server" Text="Sử dụng"></asp:Label>
                                        </td>
                                        <td style="text-align: center; width: 70px">
                                            <asp:Label ID="Label14" runat="server" Text="Giá tiền"></asp:Label>
                                        </td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:TextBox ID="tbMa" runat="server" Width="70px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="dlType" runat="server">
                                                <asp:ListItem Value="0">Thuốc</asp:ListItem>
                                                <asp:ListItem Value="1">Vật Tư</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="tbTen" runat="server" Width="70px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="tbMota" runat="server" Width="70px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="tbDonvi" runat="server" Width="70px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="tbSudung" runat="server" Width="70px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="tbTile" runat="server" Width="70px"></asp:TextBox>
                                        </td>
                                        <td>
                                            <asp:Button ID="btThemThuoc" runat="server" Text="Thêm" OnClick="btThemThuoc_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
    </table>
</asp:Content>

